<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
    pageContext.setAttribute("PAGETITLE", "用户编辑");
%>
<%@ include file="/pages/include/header.jsp" %>

<script type="text/javascript">
<!--
function confirmPassword() {
    var p1 = $E("form.loginPassword").value;
    var p2 = $E("password").value;
    if (p1 !== p2) {
        var ar = $("#action_result");
        ar.html("登录密码和确认密码不一致");
        ar.addClass("action_result_0");
        ar.animate({left: -ar.width(), opacity: "hide"}, 0);
        $C.showTips({selector: "#action_result", position: $C.P_LEFT, hide: true});
    }
}

$(document).ready(function () {
    var ar = $("#action_result");
    var i = parseInt(ar.html());
    if (0 < i) {
        ar.addClass("action_result_1");
        ar.html("操作成功");
    } else if (0 === i) {
        ar.addClass("action_result_0");
        ar.html("操作失败");
    }
    if (ar.html()) {
        $C.showTips({selector: "#action_result", position: $C.P_LEFT, hide: true});
    } else {
        ar.animate({left: -100, opacity: "hide"}, 0);
    }
});
//-->
</script>

<sql:query var="deptList" dataSource="${dataSource}">
SELECT DEPTID, DEPTNAME FROM CT_DEPARTMENT ORDER BY ORDERNO
</sql:query>

<body>

    <div class="page_header">${PAGETITLE}</div>
    
    <div class="page_buttons">
        <div id="action_result" class="action_result">${requestScope.ACTION_RESULT}</div>
        <input type="button" onclick="$('#form').submit()"
            value="${empty form.map.form.userId ? '保存' : '更新'}" />
    </div>

    <html:form action="/action/user" styleId="form">
        <input type="hidden" id="method" name="method"
            value="${empty form.map.form.userId ? 'insert' : 'update'}" />
    
        <html:hidden property="form.userId" />
        
        <table width="100%" cellpadding="0" cellspacing="0" align="center">
            <tr style="position: absolute; left: -5000px; top: -5000px;">
                <td width="20%"></td>
                <td width="80%"></td>
            </tr>
            <tr>
                <td class="label">登录名称：</td>
                <td class="value">
                    <html:text property="form.loginName" style="width: 98%;" />
                </td>
            </tr>
            <tr>
                <td class="label">登录密码：</td>
                <td class="value">
                    <html:password property="form.loginPassword" styleId="form.loginPassword" style="width: 98%;" />
                </td>
            </tr>
            <tr>
                <td class="label">确认密码：</td>
                <td class="value">
                    <input type="password" id="password" style="width: 98%;" onchange="confirmPassword()" />
                </td>
            </tr>
            <tr>
                <td class="label">用户名称：</td>
                <td class="value">
                    <html:text property="form.userName" style="width: 98%;" />
                </td>
            </tr>
            <tr>
                <td class="label">性别：</td>
                <td class="value">
                    <label for="form.gender1">
                        <html:radio property="form.gender" styleId="form.gender1" value="1" />男
                    </label>
                    <label for="form.gender0">
                        <html:radio property="form.gender" styleId="form.gender0" value="0" />女
                    </label>
                </td>
            </tr>
            <tr>
                <td class="label">手机：</td>
                <td class="value">
                    <html:text property="form.mobile" style="width: 98%;" />
                </td>
            </tr>
            <tr>
                <td class="label">电话：</td>
                <td class="value">
                    <html:text property="form.telephone" style="width: 98%;" />
                </td>
            </tr>
            <tr>
                <td class="label">所在部门：</td>
                <td class="value">
                    <html:select property="form.deptId" style="width: 98%;">
                        <html:option value=""></html:option>
                        <c:forEach var="item" items="${deptList.rows}">
                        <html:option value="${item.DEPTID}">${item.DEPTNAME}</html:option>
                        </c:forEach>
                    </html:select>
                </td>
            </tr>
            <tr>
                <td class="label">状态：</td>
                <td class="value">
                    <html:select property="form.status">
                        <html:option value=""></html:option>
                        <html:option value="1">有效</html:option>
                        <html:option value="0">无效</html:option>
                    </html:select>
                </td>
            </tr>
            <tr>
                <td class="label">排序号：</td>
                <td class="value">
                    <html:text property="form.orderNo" styleClass="number" maxlength="7" />
                </td>
            </tr>
            <tr>
                <td class="label">备注：</td>
                <td class="textarea">
                    <html:textarea property="form.remark" style="width: 98%;" rows="5" />
                </td>
            </tr>
        </table>
    </html:form>
    
    <div class="page_footer"></div>

</body>

<%@ include file="/pages/include/footer.jsp" %>
